import 'package:flutter/material.dart';
import 'package:secend_flutter/bean/home_common_model_bean.dart';
import 'package:secend_flutter/bean/home_grid_nav_model_bean.dart';
import 'package:secend_flutter/define_widget/webview_widget.dart';

class LocaNavigator extends StatelessWidget {
  final List<CommonBean> locaList;
  const LocaNavigator({Key? key, required this.locaList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 64,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(6))
      ),
      child: Padding(padding: EdgeInsets.all(6),
      child: _items(context),
      ),
    );
  }

  _items(BuildContext context) {
    List<Widget> items = [];
    locaList.forEach((model) {
      items.add(_item(context, model));
    });
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: items,
    );
  }

  Widget _item(BuildContext context, CommonBean bean) {
    return GestureDetector(
      onTap: () {
        Navigator.push(
            context,
            MaterialPageRoute(builder: (context)=>MyWebView(url: bean.url, statusBarColor: bean.statusBarColor,  hideAppBar: bean.hideAppBar)));
      },
      child: Column(
        children: <Widget>[
          Image.network(
            bean.icon!,
            width: 32,
            height: 32,
          ),
          Text(
            bean.title!,
            style: TextStyle(fontSize: 12),
          )
        ],
      ),
    );
  }
}